import Vue from 'vue'
import VueRouter from 'vue-router'
import NProgress from 'nprogress'
const Home = () => import('view/home')
const Association = () => import('view/association/Index')
const layout = () => import('components/component/layout')
// const About = () => import('view/association/about')
const AcProduction = () => import('view/association/about/production')
const Constitution = () => import('view/association/about/constitution')
const acContact = () => import('view/association/about/contact')
const Journal = () => import('view/association/about/journal')
const Special = () => import('view/association/about/special')
const Leader = () => import('view/association/about/leader')
const Organization = () => import('view/association/about/organization')
// const Part = () => import('view/association/part')

const Regulations = () => import('view/regulations/Index')
const ReCountry = () => import('view/regulations/country')
const FileV = () => import('view/regulations/file')
const Local = () => import('view/regulations/local')
const ruleDetail = () => import('view/detail')
const installDetail = () => import('view/detail2')

const Party = () => import('view/party/Index')
const Affairs = () => import('view/party/affairs')
const Building = () => import('view/party/build')

const DDown = () => import('view/down/Index')
const DResult = () => import('view/down/result')
const Dcreate = () => import('view/down/create')
const Dstandard = () => import('view/down/standard')
const Dreview = () => import('view/down/review')

const Expert = () => import('view/expert/Index')
const DataBase = () => import('view/expert/database')
const Commiter = () => import('view/expert/commiter')
const Committee = () => import('view/expert/committee')

const Train = () => import('view/train/Index')
const Notice = () => import('view/train/notice')
const Cloud = () => import('view/train/cloud')
const Down = () => import('view/train/down')
const Search = () => import('view/train/search')

const Vip = () => import('view/vip/Index')
const Vsupplier = () => import('view/vip/supplier')
const Vform = () => import('view/vip/form')
const Vfinal = () => import('view/vip/final')
const VUpdate = () => import('view/vip/update')
const VSearch = () => import('view/vip/search')

const Innovation = () => import('view/innovation/Index')
const Technological = () => import('view/innovation/technological')
const Twork = () => import('view/innovation/work')
const Tweek = () => import('view/innovation/week')
const Tcreate = () => import('view/innovation/create')
const TList = () => import('view/innovation/tecCreate/list')
const Tworld = () => import('view/innovation/world')
const Tcategory = () => import('view/innovation/category')
const Tproject = () => import('view/innovation/project')
const Tview = () => import('view/innovation/view')
const Star = () => import('view/innovation/star')
const SNotice = () => import('view/innovation/supplierSystem/notice')
const SFile = () => import('view/innovation/supplierSystem/file')
const SWay = () => import('view/innovation/supplierSystem/way')
const PDF = () => import('view/innovation/pdf')
const IFirst = () => import('view/innovation/supplierSystem/first')
const ISecond = () => import('view/innovation/supplierSystem/second')
const Ithird = () => import('view/innovation/supplierSystem/third')
const IFour = () => import('view/innovation/supplierSystem/four')
const SList = () => import('view/innovation/supplierSystem/list')
const IFive = () => import('view/innovation/supplierSystem/five')
const ISix = () => import('view/innovation/supplierSystem/six')
const Ifinal = () => import('view/innovation/supplierSystem/final')
const cFirst = () => import('view/innovation/tecCreate/first')
const cSecond = () => import('view/innovation/tecCreate/second')
const cFinal = () => import('view/innovation/tecCreate/final')

const Installer = () => import('view/installer/Index')
const Cost = () => import('view/installer/cost/index')
const cRules = () => import('view/installer/cost/rules')
const cPrice = () => import('view/installer/cost/price')
const cInformation = () => import('view/installer/cost/information')

const Bim = () => import('view/installer/bim/index')
const BCase = () => import('view/installer/bim/case')
const B3D = () => import('view/installer/bim/3d')

const Excellence = () => import('view/installer/excellence/index')
const EVideo = () => import('view/installer/excellence/home')

const Assess = () => import('view/installer/pages/assess')
const Serve = () => import('view/serve/Index')
const Evaluation = () => import('view/installer/evaluate/index')
const eNotice = () => import('view/installer/evaluate/notice')
const eManage = () => import('view/installer/evaluate/manage')
const eDown = () => import('view/installer/evaluate/down')
const eSeach = () => import('view/installer/evaluate/search')

const cloudRoom = () => import('view/installer/class/index')
const CNotice = () => import('view/installer/class/notice')
const CLive = () => import('view/installer/class/live')
const CDown = () => import('view/installer/class/down')
const CSeach = () => import('view/installer/class/search')

const IRecord = () => import('view/installer/record/index')
const INotice = () => import('view/installer/record/notice')
const IRules = () => import('view/installer/record/rules')
const ISupplier = () => import('view/installer/record/supplier')
const ISearch = () => import('view/installer/record/search')

const CCompletion = () => import('view/installer/completion/index')
const CCase = () => import('view/installer/completion/case')
const CRules = () => import('view/installer/completion/rules')
const CTable = () => import('view/installer/completion/table')

const Promotion = () => import('view/installer/promotion/index')
const PNotice = () => import('view/installer/promotion/notice')
const PRules = () => import('view/installer/promotion/rules')
const PManage = () => import('view/installer/promotion/manage')
const PSystem = () => import('view/installer/promotion/system')
const PResuslts = () => import('view/installer/promotion/results')
const login = () => import('view/login')

const error_404 = () => import('view/error')
// import { is_android, is_iphone, delSessionStorage } from 'lib/until'
// import { delSessionStorage } from 'lib/until'
// import {
//   tracker
// } from 'lib/analytics'
Vue.use(VueRouter)

let routes = [
  {
    path: "/",
    redirect: '/home'
  }, {
    path: "/login",
    component: login
  }, {
    path: '/',
    component: layout,
    children: [
      {
        path: '/installer',
        name: 'installer',
        redirect: '/installer/cost/rules',
        component: Installer,
        meta: {
          blue: true
        },
        children: [{
          path: 'cost',
          name: 'cost',
          component: Cost,
          children: [{
            path: 'rules',
            name: 'cRules',
            component: cRules
          }, {
            path: 'price',
            name: 'cPrice',
            component: cPrice
          }, {
            path: 'information',
            name: 'cInformation',
            component: cInformation
          }]
        }, {
          path: 'bim',
          name: 'Ibim',
          component: Bim,
          children: [{
            path: 'case',
            name: 'bcase',
            component: BCase
          }, {
            path: '3d/:id',
            name: '3d',
            component: B3D
          }]
        }, {
          path: 'assess',
          name: 'Iassess',
          component: Assess
        }, {
          path: 'cloud',
          name: 'Icloudroom',
          redirect: '/installer/cloud/notice',
          component: cloudRoom,
          children: [{
            path: 'notice',
            name: 'cNotice',
            component: CNotice
          }, {
            path: 'live',
            name: 'live',
            component: CLive
          }, {
            path: 'down',
            name: 'cDown',
            component: CDown
          }, {
            path: 'seach',
            name: 'cSeach',
            component: CSeach
          }]
        }, {
          path: 'record',
          name: 'IRecord',
          redirect: '/installer/record/rules',
          component: IRecord,
          children: [{
            path: 'rules',
            name: 'IRules',
            component: IRules
          }, {
            path: 'notice',
            name: 'INotice',
            component: INotice
          }, {
            path: 'supplier',
            name: 'ISupplier',
            component: ISupplier
          }, {
            path: 'search',
            name: 'ISearch',
            component: ISearch
          }]
        }, {
          path: 'completion',
          name: 'CCompletion',
          redirect: '/installer/completion/rules',
          component: CCompletion,
          children: [{
            path: 'rules',
            name: 'CRules',
            component: CRules
          }, {
            path: 'case',
            name: 'CCase',
            component: CCase
          }, {
            path: 'table',
            name: 'CTable',
            component: CTable
          }]
        }, {
          path: 'promotion',
          name: 'promotion',
          redirect: '/installer/promotion/rules',
          component: Promotion,
          children: [{
            path: 'rules',
            name: 'PRules',
            component: PRules
          }, {
            path: 'notice',
            name: 'PNotice',
            component: PNotice
          }, {
            path: 'manage',
            name: 'PManage',
            component: PManage
          }, {
            path: 'system',
            name: 'PSystem',
            component: PSystem
          }, {
            path: 'results',
            name: 'PResuslts',
            component: PResuslts
          }]
        }, {
          path: 'excellence',
          name: 'excellence',
          component: Excellence,
          children: [{
            path: 'index/:id',
            name: 'EVideo',
            component: EVideo
          }]
        }, {
          path: 'evaluation',
          name: 'Ievaluation',
          component: Evaluation,
          children: [{
            path: 'notice',
            name: 'eNotice',
            component: eNotice
          }, {
            path: 'manage',
            name: 'emanage',
            component: eManage
          }, {
            path: 'down',
            name: 'eDown',
            component: eDown
          }, {
            path: 'seach',
            name: 'eSeach',
            component: eSeach
          }]
        }, {
          path: 'cost',
          name: 'cost1',
          component: Cost
        }]
      }, {
        path: '/serve',
        name: 'serve',
        component: Serve
      }, {
        path: '/home',
        name: 'home',
        component: Home,
        meta: {
          blue: true
        }
      }, {
        path: '/fold/:id',
        component: ruleDetail
      }, {
        path: '/installer/:id',
        component: installDetail
      }, {
        path: '/association',
        name: 'association',
        redirect: '/association/product',
        component: Association,
        children: [{
          path: 'product',
          name: 'acProduct',
          component: AcProduction
        }, {
          path: 'constitution',
          name: 'constitution',
          component: Constitution
        }, {
          path: 'contact',
          name: 'contact',
          component: acContact
        }, {
          path: 'journal',
          name: 'journal',
          component: Journal
        }, {
          path: 'special',
          name: 'special',
          component: Special
        }, {
          path: 'person',
          name: 'person',
          component: Leader
        }, {
          path: 'organization',
          name: 'organization',
          component: Organization
        }]
      }, {
        path: '/regulations',
        name: 'regulations',
        redirect: '/regulations/country',
        component: Regulations,
        children: [{
          path: 'country',
          name: 'country',
          component: ReCountry
        }, {
          path: 'local',
          name: 'local',
          component: Local
        }, {
          path: 'file',
          name: 'file',
          component: FileV
        }]
      }, {
        path: '/party',
        name: 'party',
        redirect: '/party/affairs',
        component: Party,
        children: [{
          path: 'affairs',
          name: 'affairs',
          component: Affairs
        }, {
          path: 'building',
          name: 'pBuild',
          component: Building
        }]
      }, {
        path: '/down',
        name: 'ddown',
        redirect: '/down/result',
        component: DDown,
        children: [{
          path: 'result',
          name: 'result',
          component: DResult
        }, {
          path: 'create',
          name: 'Dcreate',
          component: Dcreate
        }, {
          path: 'standard',
          name: 'standard',
          component: Dstandard
        }, {
          path: 'review',
          name: 'review',
          component: Dreview
        }]
      }, {
        path: '/expert',
        name: 'expert',
        redirect: '/expert/committee',
        component: Expert,
        children: [{
          path: 'dataBase',
          name: 'dataBase',
          component: DataBase
        }, {
          path: 'commiter',
          name: 'commiter',
          component: Commiter
        }, {
          path: 'committee',
          name: 'committee',
          component: Committee
        }]
      }, {
        path: '/train',
        name: 'train',
        redirect: '/train/notice',
        component: Train,
        children: [{
          path: 'notice',
          name: 'notice',
          component: Notice
        }, {
          path: 'cloud',
          name: 'cloud',
          component: Cloud
        }, {
          path: 'down',
          name: 'tDown',
          component: Down
        }, {
          path: 'search',
          name: 'Tsearch',
          component: Search
        }]
      }, {
        path: '/vip',
        name: 'vip',
        redirect: '/vip/search',
        component: Vip,
        children: [{
          path: 'search',
          name: 'vsearch',
          component: VSearch
        }, {
          path: 'supplier/notice',
          name: 'vsupplier',
          component: Vsupplier
        }, {
          path: 'supplier/form',
          name: 'Vform',
          component: Vform
        }, {
          path: 'supplier/final',
          name: 'Vfinal',
          component: Vfinal
        }, {
          path: 'update',
          name: 'vupdate',
          component: VUpdate
        }]
      }, {
        path: '/innovation/supplier/notice',
        name: 'SNotice',
        component: SNotice
      }, {
        path: '/innovation/create/file',
        name: 'SFile',
        component: SFile
      }, {
        path: '/innovation/create/way',
        name: 'SWay',
        component: SWay
      }, {
        path: '/innovation/pdf',
        name: 'pdf',
        component: PDF
      }, {
        path: '/innovation/supplier/1',
        name: 'first',
        component: IFirst
      }, {
        path: '/innovation/supplier/2',
        name: 'second',
        component: ISecond
      }, {
        path: '/innovation/supplier/3',
        name: 'Ithird',
        component: Ithird
      }, {
        path: '/innovation/supplier/4',
        name: 'IFour',
        component: IFour
      }, {
        path: '/innovation/supplier/5',
        name: 'IFive',
        component: IFive
      }, {
        path: '/innovation/supplier/6',
        name: 'ISix',
        component: ISix
      }, {
        path: '/innovation/supplier/final',
        name: 'Ifinal',
        component: Ifinal
      }, {
        path: '/innovation/create/1',
        name: 'crfirst',
        component: cFirst
      }, {
        path: '/innovation/create/2',
        name: 'crsecond',
        component: cSecond
      }, {
        path: '/innovation/create/final',
        name: 'cFinal',
        component: cFinal
      }, {
        path: '/innovation',
        name: 'innovation',
        redirect: '/innovation/technological',
        component: Innovation,
        children: [{
          path: 'technological',
          name: 'technological',
          component: Technological
        }, {
          path: 'star',
          name: 'star',
          component: Star
        }, {
          path: 'supplier/list',
          name: 'sList',
          component: SList
        }, {
          path: 'work',
          name: 'work',
          component: Twork
        }, {
          path: 'week',
          name: 'week',
          component: Tweek
        }, {
          path: 'create',
          name: 'create',
          component: Tcreate
        }, {
          path: 'list',
          name: 'cList',
          component: TList
        }, {
          path: 'world',
          name: 'world',
          component: Tworld
        }, {
          path: 'category',
          name: 'category',
          component: Tcategory
        }, {
          path: 'project',
          name: 'project',
          component: Tproject
        }, {
          path: 'view',
          name: 'view',
          component: Tview
        }]
      }, {
        path: '/404',
        name: 'error_404',
        component: error_404
      }
    ]
  }
]
const router = new VueRouter({
  routes,
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  }
})
const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return routerPush.call(this, location).catch(error => error)
}
router.beforeEach((to, from, next) => {
  NProgress.start()
  next()
})
router.afterEach(route => {
  NProgress.done()
  window.scrollTo(0, 0)
  document.body.scrollTop = document.documentElement.scrollTop = 0
})

export default router
